package jp.sourceforge.akjrcp.util.directorybased;

import com.akjava.lib.standards.process.ProcessPrinter;

import java.io.File;
import java.io.IOException;

public class RenameCommand implements DirectoryBasedCommand{
private File srcName;
private File destName;
public RenameCommand(File srcName, File destName){
	this.srcName=srcName;
	this.destName=destName;
}
	public int exec() throws IOException {
		if(srcName==null || destName==null){
			return -1;
		}
		boolean result=srcName.renameTo(destName);
		if(result){
			return 0;
		}else{
			return -1;
		}
	}

	public Process getProcess() {
		// TODO Auto-generated method stub
		return null;
	}

	public void setProcessPrinter(ProcessPrinter processPrinter) {
		try {
			processPrinter.printOutput("rename from "+srcName+" to "+destName+"\r\n");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
